<jsp:useBean id="userInfoMap" scope="request" class="java.util.HashMap"/>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
        <meta name="description" content="" />
        <meta name="author" content="" />
        <title>后台</title>
        <link href="${pageContext.request.contextPath}/admin/css/glyphicon.css" rel="stylesheet" />
        <link href="${pageContext.request.contextPath}/admin/css/styles.css" rel="stylesheet" />
        <script src="${pageContext.request.contextPath}/admin/js/all.js"></script>
    </head>
    <body class="sb-nav-fixed">
    	<%@ include file="include/head.jsp" %>
        <div id="layoutSidenav">
        	<%@ include file="include/nav.jsp" %>

            <div id="layoutSidenav_content">
            	<div class="container-fluid px-4">





                	<div class="card mb-4">
                    	<div class="card-header">
                        	<i class="fas fa-table me-1"></i>
                            	表格
                        </div>
                        <div class="card-body">
                        	<a href="${pageContext.request.contextPath}/admin/addUser.jsp">
                        		<button class="btn btn-primary">添加用户</button>
                        	</a><br><br>
                        	<table id="datatablesSimple" >
                            	<thead>
                                	<tr>
                                    	<th>学号</th>
                                    	<th>姓名</th>
                                    	<th>密码</th>
                                    	<th>性别</th>
                                        <th>邮箱</th>
                                    	<th>电话号码</th>
                                    	<th>职位</th>
                                    	<th>编辑</th>
                               		</tr>
                           		</thead>
                                <tbody>


								<c:forEach items="${userInfo.entrySet()}" var="entry"> <!-- 遍历HashMap的entrySet -->
									<c:set var="user" value="${entry.value}"/> <!-- 将当前迭代的value（User对象）赋给user变量 -->
									<tr>
										<td>${entry.key}</td> <!-- 展示HashMap的key，假设它是用户ID -->
										<td>${user.name}</td>
										<td>${user.password}</td>
										<td>${user.sex}</td>
										<td>${user.mailbox}</td>
										<td>${user.phone}</td>
										<td>${user.role}</td>
										<td>
											<a href="${pageContext.request.contextPath}/EditUser?id=${entry.key}">
												<button type="button" class="btn btn-default">
													<i class="glyphicon glyphicon-pencil"></i>修改
												</button>
											</a>
											<a href="${pageContext.request.contextPath}/deleteUser?id=${entry.key}" methods="get">
												<button type="button" class="btn btn-default">
													<i class="glyphicon glyphicon-trash"></i>删除
												</button>
											</a>
										</td>
									</tr>
								</c:forEach>
                                	
                                	

                         		</tbody>
               				</table>
                   		</div>
             		</div>





                </div>
                <%@ include file="include/foot.jsp" %>
			</div>
        </div>
        <script src="${pageContext.request.contextPath}/admin/js/bootstrap.min.js"></script>
        <script src="${pageContext.request.contextPath}/admin/js/scripts.js"></script>
        <script src="${pageContext.request.contextPath}/admin/js/simple-datatables@latest.js"></script>
        <script src="${pageContext.request.contextPath}/admin/js/datatables-simple-demo.js"></script>
    </body>
</html>